// 导入axios
import axios from 'axios';
import {
    Message
} from 'element-ui';

axios.defaults.baseURL = "http://192.168.101.53:8568";
// axios.defaults.baseURL = "http://101.201.74.142:6688";

// 请求响应超时时间
axios.defaults.timeout = 30000;
axios.interceptors.request.use(config => {
    config.headers['Content-Type'] = 'application/json'
    return config
})
export default {
    get: function(path = '', data = {}) {
        return new Promise(function(resolve, reject) {
            axios.get(path, {
                    params: data
                })
                .then(function(response) {
                    resolve(response);
                })
                .catch(function(error) {
                    reject(error);
                });
        });
    },
    post: function(path = '', data = {}) {
        return new Promise(function(resolve, reject) {
            axios.post(path,data)
                .then(function(response) {
                  resolve(response)
                })
                .catch(function(error) {
                    reject(error);
                });
        });
    }
};
